#ifndef __ALARM_MODULE_H__
#define __ALARM_MODULE_H__

#include "common.h"
#include "global_config.h"

/* Maximum number of alarms */
#define MAX_ALARMS 10

/* Alarm types */
typedef enum {
    ALARM_TEMPERATURE_HIGH = 1,
    ALARM_TEMPERATURE_LOW,
    ALARM_PRESSURE_HIGH,
    ALARM_PRESSURE_LOW,
    ALARM_FLOW_HIGH,
    ALARM_FLOW_LOW,
    ALARM_WATER_QUALITY,
    ALARM_COMMUNICATION,
    ALARM_SYSTEM
} alarm_type_t;

/* Alarm message structure */
typedef struct {
    alarm_type_t type;
    alarm_level_t level;
    uint8_t channel;
    float value;
    float limit;
    rt_bool_t triggered;
    uint32_t timestamp;
} alarm_info_t;

/* Function declarations */
rt_err_t alarm_module_init(void);
void alarm_thread_entry(void *parameter);
rt_err_t alarm_check_all(void);
rt_err_t alarm_acknowledge(uint8_t alarm_index);
rt_err_t alarm_set_limits(uint8_t alarm_index, float low_limit, float high_limit, alarm_level_t level);
rt_uint32_t alarm_get_active_count(void);
rt_bool_t alarm_is_triggered(uint8_t alarm_index);

/* External configuration access */
extern alarm_config_t *alarm_get_config(void);

#endif /* __ALARM_MODULE_H__ */